function getImage()
{
  tfTextTxt = document.getElementById('tfText').value;
  tfSizeTxt = document.getElementById('tfSize').value;
  tfXTxt = document.getElementById('tfX').value;
  tfYTxt = document.getElementById('tfY').value;
  if(tfTextTxt == "" || tfSizeTxt == "" || tfXTxt == "" ||
     tfYTxt == ""){
    alert("Proszę wypełnić wszystkie pola.");
    return;
  }
  params="?text=" + tfTextTxt + "&size=" + tfSizeTxt;
  params += "&x=" + tfXTxt + "&y=" + tfYTxt;

  url = "http://localhost/dane.php" + params;
  url = encodeURI(url);

  var btnWykonaj = document.getElementById('btnWykonaj');
  btnWykonaj.disabled = true;
  startGETRequest(url, onComplete, onEnd);
}

function onComplete(text, xml)
{
  if(text.substr(0, 5) == 'error'){
    arr = text.split("\n");
    if(arr.length == 2){
      if(arr[0] == 'error')
        alert(arr[1]);
      else
        alert("Nieprawidłowa odpowiedź serwera.");
    }
  }
  else{
    var img1 = document.getElementById('img1');
    url = "image.php?name=" + text;
    url = encodeURI(url);
    img1.src = url;
  }
}

function onEnd()
{
  var btnWykonaj = document.getElementById('btnWykonaj');
  btnWykonaj.disabled = false;
}
